// src/mock/mock.js
import Mock from 'mockjs';

const users = [
  {
    username: 'user1',
    password: 'password1',
  },
  {
    username: 'user2',
    password: 'password2',
  },
];

Mock.mock('/api/login', 'post', (options) => {
  const { username, password } = JSON.parse(options.body);
  const user = users.find(
    (u) => u.username === username && u.password === password
  );
  return user ? { success: true, message: '登录成功' } : { success: false, message: '账号或密码错误' };
});
